package com.amado.springcloud.user.fegin;

import com.amado.springcloud.user.entity.User;
import com.amado.springcloud.user.service.IUserService;
import com.amado.springcloud.user.vo.SNSResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wangyl-910
 * @description
 * @date 2017/12/18
 * @see
 */
@RestController
public class UserFeginImpl implements UserFeign{
    @Autowired
    private IUserService userService;
    @Override
    public SNSResult<User> getUser(@PathVariable("id")Long id) {
        return new SNSResult<>(userService.getById(id));
    }

    @Override
    public SNSResult<Void> addUser(User user) {
        userService.save(user);
        return new SNSResult<>();
    }

    @Override
    public SNSResult<Void> updateUser(User user) {
        userService.updateById(user);
        return new SNSResult<>();
    }

    @Override
    public SNSResult<Void> deleteUser(Long id) {
        userService.removeById(id);
        return new SNSResult<>();
    }
}